import React from 'react';
import { MenuItem } from '@mui/material';
import { Box } from '@mui/material';
import ListComponent from '../../general/List';
import NetPyNEField from '../../general/NetPyNEField';
import NetPyNESelectField from '../../general/NetPyNESelectField';
import NetPyNECoordsRange from '../../general/NetPyNECoordsRange';

interface StimulationConditionsProps {
  name: string;
  [key: string]: any;
}

const StimulationConditions: React.FC<StimulationConditionsProps> = ({ name, ...otherProps }) => {
  const postProcessMenuItems = (pythonData: string[], selected: string[]): React.ReactNode[] => {
    return pythonData.map((name) => (
      <MenuItem
        id={`${name}MenuItem`}
        key={name}
        value={name}
        selected={selected.indexOf(name) > -1}
      >
        {name}
      </MenuItem>
    ));
  };

  return (
    <Box className="scrollbar scrollchild" mt={1}>
      <NetPyNEField id="netParams.stimTargetParams.conds.pop">
        <NetPyNESelectField
          model={`netParams.stimTargetParams['${name}']['conds']['pop']`}
          method="netpyne_geppetto.getAvailablePops"
          postProcessItems={postProcessMenuItems}
          multiple
          fullWidth
        />
      </NetPyNEField>

      <NetPyNEField id="netParams.stimTargetParams.conds.cellType">
        <NetPyNESelectField
          model={`netParams.stimTargetParams['${name}']['conds']['cellType']`}
          method="netpyne_geppetto.getAvailableCellTypes"
          postProcessItems={postProcessMenuItems}
          multiple
          fullWidth
        />
      </NetPyNEField>

      <NetPyNECoordsRange
        id="xRangeStimTarget"
        name={name}
        model="netParams.stimTargetParams"
        conds="conds"
        items={[
          {
            value: 'x',
            label: 'Absolute',
          },
          {
            value: 'xnorm',
            label: 'Normalized',
          },
        ]}
      />

      <NetPyNECoordsRange
        id="yRangeStimTarget"
        name={name}
        model="netParams.stimTargetParams"
        conds="conds"
        items={[
          {
            value: 'y',
            label: 'Absolute',
          },
          {
            value: 'ynorm',
            label: 'Normalized',
          },
        ]}
      />

      <NetPyNECoordsRange
        id="zRangeStimTarget"
        name={name}
        model="netParams.stimTargetParams"
        conds="conds"
        items={[
          {
            value: 'z',
            label: 'Absolute',
          },
          {
            value: 'znorm',
            label: 'Normalized',
          },
        ]}
      />
    </Box>
  );
};

export default StimulationConditions;

